<?php

namespace app\home\controller;
use app\comm\controller\PcLogController;
use app\comm\service\ChartService;
class Work extends PcLogController{

	/**
	 * liaotian 
	 * @return [type] [description]
	 */
	public function index(){
		$chartservice = new ChartService;
		$list  = $chartservice ->getkefu();
		$roe = $this->userinfo;

		$roe['uid'] ="forent".$roe['uid'];
		$info 	= json_encode(['nickname'=>$roe['nickname'],"logo"=>$roe['logo']]);
		return view('work/index',['list'=>$list,"userinfo"=>$roe,"info"=>$info]);
	}

	/**
	 * 发送消息
	 */
	public function sendms(){
		$client=request()->get("client");
		$msg=request()->get("msg");
		$data=["msg"=>$msg,"type"=>2];
		$msgs = json_encode($data);
		$this->sendbyclient($client,$msgs);
	}

	/**
	 * 绑定uid
	 */
	public function binduidbyclient(){
		$client = request()->get("client");
		$uid = request()->get("uid");
		$this->bindbyuid($client,$uid);
	}

	/**
	 * uid 发送消息 xiaoxi type =1
	 */
	public function sedmsuid(){
		$fromuid=request()->get("fromuid");
		$touid=request()->get("touid");
		$msg=request()->get("msg");
		$type=request()->get("type");
		$userinfo=request()->get("userinfo");
		if(!$this->isonline($touid))return "不在线";
		$data= ["fromuid"=>$fromuid,"touid"=>$touid,'msg'=>$msg ,'type'=>$type, 
				"userinfo"=>$userinfo];
		$this->sendmsg($touid,json_encode($data));
		return json($data);
	}

	/**
	 * 是否在线
	 */
	public function isonline(){
		$touid=request()->get("touid");
		$result = $this->isparonline($touid);
		return $result;
	}

	/*********************************************/
	/**
	 * 后台发送消息
	 * @return [type] [description]
	 */
	public function test(){
		return view('work/test',['kefu1'=>"backend10007"]);
		//$this->bindbyuid($client,$this->userinfo['uid']);
	}

	/**
	 * 绑定id
	 * @param  [type] $client [description]
	 * @return [type]         [description]
	 */
	public function binduidbyclientadmin(){
		$client=request()->get("client");
		$uid=request()->get("uid");
		$this->bindbyuid($client,$uid);
	}



}